﻿@using TestConsole

@if (Controls != null)
{
    @for (int i = 0; i < Controls.Count; i++)
    {
        var ctl = Controls[i];
        if (ctl is InputInfo input)
        {
            if (input.GType == GType.none)
            {
                if (input.InputType == InputType.date)
                {
                    <p>@input.Label</p>
                    <p>@input.DateValue</p>
                }
                else if (input.InputType == InputType.text)
                {
                    <p>@input.Label</p>
                    <p>@input.StringValue</p>
                }
                else if (input.InputType == InputType.password)
                {
                    <p>@input.Label</p>
                    <p>@input.StringValue</p>
                }
                else
                {
                    throw new Exception($"不应该走此分支");
                }
            }
            else if (input.GType == GType.radio)
            {
                <p>@input.Label</p>
                <p>@input.StringValue</p>
            }
            else if (input.GType == GType.checkbox)
            {
                <p>@input.Label</p>
                <p>@input.StringValue</p>
            }
            else
            {
                throw new Exception($"不应该走此分支");
            }
        }
        else if (ctl is TextareaInfo area)
        {
            <p>@area.Label</p>
            <p>@area.StringValue</p>
        }
        else if (ctl is SelectInfo select)
        {
            <p>@select.Label</p>
            if (select.IsMultiple)
            {
                <p>@(string.Join(" ",select.MultiStringValue.ToArray()??Array.Empty<string>()))</p>}
            else
            {
                <p>@select.StringValue</p>}
        }
        else
        {
            throw new Exception($"{ctl.GetType().Name}目前代码不支持");
        }
    }
}

